package com.clsfd.database;

import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;

public class Advert {
	
	
	private DatabaseConnection MysqlConn=null;
	private int AdvertID=0;
	private Timestamp EntryTime=null;
	private String Servicetype ="";
	private String Language="";
	private String MSISDN="";
	private String PromptName="";
	private Timestamp ActivatedTime=null;
	private String MobileOperator="";
	
	
	public Advert(DatabaseConnection mysqlConn, int advertID,
			Timestamp entryTime, String servicetype, String language,
			String mSISDN, String promptName, Timestamp activatedTime,
			String mobileOperator) {
		super();
		MysqlConn = mysqlConn;
		AdvertID = advertID;
		EntryTime = entryTime;
		Servicetype = servicetype;
		Language = language;
		MSISDN = mSISDN;
		PromptName = promptName;
		ActivatedTime = activatedTime;
		MobileOperator = mobileOperator;
	}


	public Date getActivatedtime() {
		return ActivatedTime;
	}

	
	public void setActivatedtime(String activatedtime) throws SQLException, ParseException {
		this.ActivatedTime = new Timestamp(( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(activatedtime)).getTime());
		MysqlConn.sqlUpdate("update `Advert` set `activatedtime`='"+activatedtime+"' where `AdvertID`="+AdvertID);
	}

	public String getServicetype() {
		return Servicetype;
	}


	public void setServicetype(String servicetype) throws SQLException {
		this.Servicetype = servicetype;
		MysqlConn.sqlUpdate("update `Advert` set `servicetype`='"+servicetype+"' where `AdvertID`="+AdvertID);
		
	}


	public int getAdvertID() {
		return AdvertID;
	}


	public String getMobileOperator() {
		return MobileOperator;
	}


	public void setMobileOperator(String mobileOperator) throws SQLException {
		MobileOperator = mobileOperator;
		MysqlConn.sqlUpdate("update `Advert` set `operator`='"+mobileOperator+"' where `AdvertID`="+AdvertID);
	}



	public Timestamp getEntryTime() {
		return EntryTime;
		
	}


	public void setEntryTime(String entryTime) throws SQLException, ParseException {
		this.EntryTime = new Timestamp(( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(entryTime)).getTime());
		MysqlConn.sqlUpdate("update `Advert` set `activatedtime`='"+entryTime+"' where `AdvertID`="+AdvertID);
	}


	public String getLanguage() {
		return Language;
	}


	public void setLanguage(String language) throws SQLException {
		Language = language;
		MysqlConn.sqlUpdate("update `Advert` set `language`='"+language+"' where `AdvertID`="+AdvertID);
	}
	

	public String getMSISDN() {
		return MSISDN;
	}


	public void setMsisdn(String msisdn) throws SQLException {
		MSISDN = msisdn;
		MysqlConn.sqlUpdate("update `Advert` set `msisdn`='"+msisdn+"'  where `AdvertID`="+AdvertID);
	}



	public String getPromptName() {
		return PromptName;
	}


	public void setPromptName(String promptName) throws SQLException {
		PromptName = promptName;
		MysqlConn.sqlUpdate("update `Advert` set `promptName`='"+promptName+"'  where `AdvertID`="+AdvertID);
	}

	public void deleteAdvert() throws SQLException {
		MysqlConn.sqlUpdate("delete from `Advert`  where `AdvertID`="+AdvertID);
	}

	

	
	
}
